package com.bestv.search.common.model;

import java.io.Serializable;
import java.util.Date;

public class SearchFieldInfo implements Serializable {
    private static final long serialVersionUID = 818185768848197222L;
    private long id;
    private String name;
    private float boost;
    private Date updateTime;
    private SysUser creator;
    private String description;

    public SysUser getCreator() {
        return creator;
    }

    public void setCreator(SysUser creator) {
        this.creator = creator;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getBoost() {
        if (boost == 0.0f)
            return 0.0f;
        int bt = Math.round(boost * 100);
        return bt / 100f;
    }

    public void setBoost(float boost) {
        this.boost = boost;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + Float.floatToIntBits(boost);
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final SearchFieldInfo other = (SearchFieldInfo) obj;
        if (Float.floatToIntBits(boost) != Float.floatToIntBits(other.boost))
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "{name: " + name + ", boost: " + boost + ", creator: " + creator.getUsername() + ", updateTime: "
                + updateTime + " }";
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
